home *** CD-ROM | disk | FTP | other *** search
- Path: lyra.csx.cam.ac.uk!nmm1
- From: nmm1@cus.cam.ac.uk (Nick Maclaren)
- Newsgroups: comp.std.c
- Subject: Re: Buffering?? What buffering??
- Date: 2 Jan 1996 10:43:33 GMT
- Organization: University of Cambridge, England
- Message-ID: <4cb28l$2gb@lyra.csx.cam.ac.uk>
- References: <4c9uk4$sa4@cygnus.com>
- NNTP-Posting-Host: ursa.cus.cam.ac.uk
-
- In article <4c9uk4$sa4@cygnus.com>, rfg@monkeys.com (Ronald F. Guilmette) writes:
- |> I would like to know the exact semantics of the _IOFBF, _IOLBF, and
- |> _IONBF mode flags for the `setvbuf' function (subclause 7.9.5.6 of the
- |> ANSI/ISO C tandard).
- |>
- |> Correct me if I'm wrong, but there doesn't seem to be any description
- |> whatsoever of the semantics of these flags in the C standard. Given
- |> that, I rather wonder why these were standardized at all. Certainly,
- |> to just say ``Here are some possible flags for this function. We don't
- |> know what they do.'' doesn't help anybody.
-
- See section 4.9.3 of the ANSI standard or the equivalent in the ISO one,
- but here is a rough description:
-
- _IONBF causes each character to be read or written as it happens.
-
- _IOLBF reads or writes data when the buffer is full or when a logical
- newline is encountered (and therein hangs a tale!)
-
- _IOFBF does this only when the buffer is full.
-
- fflush and fclose (but not necessarily rewind) cause the reading or
- writing to take place immediately.
-
-
- But remember that reading and writing refer only to C's interface
- with its environment, and not necessarily to the interaction of that
- environment with other environments or peripherals. Until you have
- tried to do it (and probably failed), you cannot imagine how foul it
- is to write a message synchronously even within a single UNIX system.
- And as for networks :-(
-
-
- Nick Maclaren,
- University of Cambridge Computer Laboratory,
- New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
- Email: nmm1@cam.ac.uk
- Tel.: +44 1223 334761 Fax: +44 1223 334679
-